const hostUrl="https://ordering.kadia.link";
const apiUrl=hostUrl+'/user/api';
const storageUrl="https://6f72-ordering-6gk15joy7343730d-1306345627.tcb.qcloud.la";
const staticUrl=storageUrl+'/static';
let tmpInfo={};
let tmpList={};
let openId='';

const cloneObj = function (obj) {
    var newObj = {};
    if (obj instanceof Array) {
        newObj = [];
    }
    for (var key in obj) {
        var val = obj[key];
        //newObj[key] = typeof val === 'object' ? arguments.callee(val) : val; //arguments.callee 在哪一个函数中运行，它就代表哪个函数, 一般用在匿名函数中。
        newObj[key] = typeof val === 'object' ? cloneObj(val): val;
    }
    return newObj;
};
const err = function(){
	uni.showToast({
		title:'请检查网络后重试',
		icon:'none',
		duration:2000
	});
}
const busy = function(){
	uni.showToast({
		title:'系统繁忙，请稍后再试',
		icon:'none',
		duration:2000
	});
}
function getRandomFileName(fileName) {
	const index = fileName.lastIndexOf(".");
	const type = fileName.substr(index + 1);
	const date = new Date();
	const name = date.getTime() + Math.random().toString(36).substr(2)+'.'+type;
	return name;
}
function PrefixZero(num, n) {
    return (Array(n).join(0) + num).slice(-n);
}
function tansf(utc_datetime) {
	const time = new Date(utc_datetime*1000);
	return time.getFullYear() + '-' + PrefixZero(time.getMonth() + 1, 2) + '-' + PrefixZero(time.getDate(), 2) + ' ' + PrefixZero(time.getHours(), 2) +
		':' + PrefixZero(time.getMinutes(), 2) + ':' + PrefixZero(time.getSeconds(), 2);
}
export default {
	hostUrl,
	apiUrl,
	storageUrl,
	staticUrl,
	openId,
	cloneObj,
	getRandomFileName,
	PrefixZero,
	tansf,
	err,
	busy,
	tmpInfo,
	tmpList
}